package com.sf.dlb.service;

import com.sf.dlb.bean.AppErrerBean;
import com.sf.dlb.mongo.model.AppErrer;
import com.sf.dlb.mongo.repository.AppErrerRepository;
import com.sf.dlb.utils.GsonUtils;
import com.sf.dlb.utils.ResultVOUtil;
import com.sf.dlb.vo.ResultVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * Created by jing.tan on 2018/5/21.
 */
@Service
public class AppErrerService {
    private static Logger logger = LoggerFactory.getLogger(AppErrerService.class);
    @Autowired
    private AppErrerRepository appErrerRepository;
    /**
     * 添加错误
     * @return
     */
    @Transactional
    public ResultVO addErrer(AppErrerBean appErrerBean){
        logger.info(" addErrer start appErrerBean={}", GsonUtils.getInstance().toJson(appErrerBean));
        AppErrer appErrer=new AppErrer();
        appErrer.setUserId(appErrerBean.getUserId());
        appErrer.setAppType(appErrerBean.getAppType());
        appErrer.setErrerLog(appErrerBean.getErrerLog());
        appErrer.setCreateDate(new Date());
        appErrer.setUpdateDate(new Date());
        appErrerRepository.save(appErrer);
        return ResultVOUtil.success();
    }
}
